CXX = c++

NAME = libCLAP.so
INCLUDES = -I./
LIBRARIES = -shared -fPIC
CFLAGS = -c -O2 -fPIC $(INCLUDES)
LINKFLAGS = -o ${NAME} ${LIBDIRS} ${LIBRARIES}
INCLUDEDIR = /usr/local/include
LIBDIR = /usr/local/lib

SOURCES =	CLAP/CLI.cpp \
				CLAP/Exception.cpp \
				CLAP/ExecutionPlan.cpp \
				CLAP/Stage.cpp \
				CLAP/SubCommand.cpp \
				CLAP/Switch.cpp \
				Common/Exception.cpp

OBJECTS =	CLAP/CLI.o \
				CLAP/Exception.o \
				CLAP/ExecutionPlan.o \
				CLAP/Stage.o \
				CLAP/SubCommand.o \
				CLAP/Switch.o \
				Common/Exception.o

HEADERS =	CLAP/CLI.h \
				CLAP/Exception.h \
				CLAP/ExecutionPlan.h \
				CLAP/Stage.h \
				CLAP/SubCommand.h \
				CLAP/Switch.h \
				CLAP/Types.h \
				Common/Exception.h \
				Common/Types.h

all  : libCLAP.so

libCLAP.so : ${OBJECTS}
	${CXX} ${LINKFLAGS} ${OBJECTS}

install : libCLAP.so
	cp libCLAP.so ${LIBDIR}
	mkdir ${INCLUDEDIR}/CLAP
	mkdir ${INCLUDEDIR}/CLAP/CLAP
	mkdir ${INCLUDEDIR}/CLAP/Common
	cp CLAP/CLI.h ${INCLUDEDIR}/CLAP/CLAP
	cp CLAP/Exception.h ${INCLUDEDIR}/CLAP/CLAP
	cp CLAP/ExecutionPlan.h ${INCLUDEDIR}/CLAP/CLAP
	cp CLAP/Stage.h ${INCLUDEDIR}/CLAP/CLAP
	cp CLAP/SubCommand.h ${INCLUDEDIR}/CLAP/CLAP
	cp CLAP/Switch.h ${INCLUDEDIR}/CLAP/CLAP
	cp CLAP/Types.h ${INCLUDEDIR}/CLAP/CLAP
	cp Common/Types.h ${INCLUDEDIR}/CLAP/Common
	cp Common/Exception.h ${INCLUDEDIR}/CLAP/Common

CLAP/CLI.o : ${SOURCES} ${HEADERS}
	${CXX} ${CFLAGS} -o CLAP/CLI.o CLAP/CLI.cpp

CLAP/Exception.o : ${SOURCES} ${HEADERS}
	${CXX} ${CFLAGS} -o CLAP/Exception.o CLAP/Exception.cpp

CLAP/ExecutionPlan.o : ${SOURCES} ${HEADERS}
	${CXX} ${CFLAGS} -o CLAP/ExecutionPlan.o CLAP/ExecutionPlan.cpp

CLAP/Stage.o : ${SOURCES} ${HEADERS}
	${CXX} ${CFLAGS} -o CLAP/Stage.o CLAP/Stage.cpp

CLAP/SubCommand.o : ${SOURCES} ${HEADERS}
	${CXX} ${CFLAGS} -o CLAP/SubCommand.o CLAP/SubCommand.cpp

CLAP/Switch.o : ${SOURCES} ${HEADERS}
	${CXX} ${CFLAGS} -o CLAP/Switch.o CLAP/Switch.cpp

Common/Exception.o : ${SOURCES} ${HEADERS}
	${CXX} ${CFLAGS} -o Common/Exception.o Common/Exception.cpp

test : clap

clap: test/CLITest.cpp ${SOURCES} ${HEADERS}
	g++ ${INCLUDES} -ggdb test/CLITest.cpp ../CLAP/CLI.cpp ../CLAP/Exception.cpp ../CLAP/ExecutionPlan.cpp ../CLAP/Stage.cpp ../CLAP/SubCommand.cpp ../CLAP/Switch.cpp ../Common/Exception.cpp -o cli

clean:
	rm -f *.o
	rm -f cli
	rm -f ${NAME}
	rm -f ${OBJECTS}
